#include <iostream>

using namespace std;
// #include "port.h"
#include "data.h"
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <cinttypes>
#include <cmath>
#include <string>
#include <experimental/filesystem>
inline void FastGzipString(const std::string &uncompressed, std::string *compressed)
{
    boost::iostreams::filtering_ostream out;
    out.push(boost::iostreams::gzip_compressor(boost::iostreams::zlib::best_speed));
    out.push(boost::iostreams::back_inserter(*compressed));
    boost::iostreams::write(out, reinterpret_cast<const char *>(uncompressed.data()), uncompressed.size());
}

inline void FastGunzipString(const std::string &compressed, std::string *decompressed)
{
    boost::iostreams::filtering_ostream out;
    out.push(boost::iostreams::gzip_decompressor());
    out.push(boost::iostreams::back_inserter(*decompressed));
    // cout << compressed.data() << endl;
    cout << compressed.size() << endl;
    boost::iostreams::write(out, reinterpret_cast<const char *>(compressed.data()), compressed.size());
}

int main(int argc, char const *argv[])
{
    cout << "start" << endl;
    // for (size_t i = 0; i < sizeof(data); i++) { printf(" %d", data[i]); }

    std::string compressed((char *)data);
    std::string decompressed;
    // cout << "\n" << compressed << "\n";
    cout << "\n" << compressed.size() << "\n";

    FastGunzipString(compressed, &decompressed);

    cout << "\n" << compressed << "\n";
    return 0;
}